1. Field of the Invention
The present invention relates to computer graphics. More particularly, it relates to simulating camera depth-of-field effects in a digital image.
2. Related Art
In computer graphics, camera depth-of-field effects are important effects that contribute to the overall realism of digital images. Camera depth-of-field effects add to the realism of digital images because only one plane in a real image, the focal plane, can be in focus at any given instance in time. The farther an object is located from the focal plane in a real image, the more out of focus or blurry it appears to an observer. Being able to quickly generate a sequence of digital images having camera depth-of-field effects is particularly important, especially in computer animation.
Conventionally, digital images having camera depth-of-field effects have been generated by combining several copies of an object to be blurred into a single image. A stationary object in a digital image would be blurred to simulate camera depth-of-field effects, for example, by generating several slightly displaced copies of the object and blending the pixels of these copies of the object to form a single blurred image of the object. This conventional method for simulating camera depth-of-field effects in digital images is highly dependent on scene complexity and geometric complexity, as are other known conventional methods. While conventional methods for simulating camera depth-of-field effects in digital images are useful in certain circumstances, the known conventional methods cannot be implemented at interactive rates on graphics machines.
What is needed is a method, system, and computer program product for simulating camera depth-of-field effects in a digital image at an interactive rate.
The present invention provides a method, system, and computer program product for simulating camera depth-of-field effects in an image. A source image having a plurality of pixels is transferred to a frame buffer. Either during the transfer or after the transfer, a blending factor is determined for each pixel of the source image. A blurred copy of the source image is generated using hardware, software, or a combination of hardware and software. The blurred copy of the source image is then blended with the source image using the determined blending factors to produce an image having simulated camera depth-of-field effects.
In an embodiment, the depth component for each of the source image pixels is used as the blending factor for each of the pixels. In another embodiment, the blending factor for each of the pixels is calculated based upon the depth component of each of the pixels. In still another embodiment, the blending factor for each of the pixels of the source image is obtained from a look-up table using the depth component of each of the pixels of the source image.
In an embodiment, the blurred copy of the source image is generated by operating on the pixels of the source image with a box filter. In another embodiment, the source image is operated on with a Gaussian filter.
According to a further feature, the present invention can be implemented on a wide range of machines including, but not limited to, low-end game systems. For example, the present invention provides camera depth-of-field effects even on a low-end game machine that does not have 3-D texturing or an accumulation buffer.
Further features and advantages of the present invention, as well as the structure and operation of various embodiments of the present invention, are described in detail below with reference to the accompanying drawings.